package com.ruoyi.electronicFence.service.impl;


import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.config.DbInterfaceConfig;
import com.ruoyi.electronicFence.domain.vo.ReqVo;
import com.ruoyi.electronicFence.domain.vo.ResVo;
import com.ruoyi.electronicFence.utils.HttpUtil;
import com.ruoyi.electronicFence.domain.DynamicsInfo;
import com.ruoyi.electronicFence.service.DynamicsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;

/**
* @author Administrator
* @description 针对表【J_KY_S_AISADSBDWXX(AIS/ADS-B动态信息表)】的数据库操作Service实现
* @createDate 2025-02-14 17:55:35
*/
@Service
public class DynamicsInfoServiceImpl
    implements DynamicsInfoService {

//    @Autowired
//    private DynamicsInfoMapper dynamicsInfoMapper;

    @Autowired
    private DbInterfaceConfig dbInterfaceConfig;

    @Override
    public String selectMaxId() {

        StringBuilder sb = new StringBuilder("select max(JJSJ) as jjsj from J_KY_S_AISADSBDWXX");
        Map<String, String> map  = (Map<String, String>) HttpUtil.getBean(dbInterfaceConfig, new ReqVo(sb.toString()), Map.class);
        return LocalDateTime.parse(map.get("jjsj"), DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }

    @Override
    public List<DynamicsInfo> getList(String rddqwz, String adsMaxId) {
        StringBuilder sb = new StringBuilder("");
        sb.append("select id, mbbm, jjsj, jd, wd from J_KY_S_AISADSBDWXX where jjsj between ")
                .append("'" + rddqwz + "'")
                .append(" and ")
                .append("'" + adsMaxId + "'");
        List<DynamicsInfo> listBean = (List<DynamicsInfo>) HttpUtil.getListBean(dbInterfaceConfig, new ReqVo(sb.toString()), DynamicsInfo.class);
        return listBean;
    }
}




